package org.lql.chaos.core.exception;

/**
 * @author: liangqinglong
 * @date: 2025-07-10 18:12
 * @description: 异常调用链Demo
 **/
public class CallChainExample {

	public static class LowLevelException extends Exception {

		public LowLevelException() {
			super();
		}

		public LowLevelException(String message, Throwable cause) {
			super(message, cause);
		}

		public LowLevelException(String message) {
			super(message);
		}

		public LowLevelException(Throwable cause) {
			super(cause);
		}
	}

	public static class MidLevelException extends Exception {

		public MidLevelException() {
			super();
		}

		public MidLevelException(String message, Throwable cause) {
			super(message, cause);
		}

		public MidLevelException(String message) {
			super(message);
		}

		public MidLevelException(Throwable cause) {
			super(cause);
		}
	}

	public static class HighLevelException extends RuntimeException {

		public HighLevelException() {
			super();
		}

		public HighLevelException(String message, Throwable cause) {
			super(message, cause);
		}

		public HighLevelException(String message) {
			super(message);
		}

		public HighLevelException(Throwable cause) {
			super(cause);
		}
	}

	public static void fa() throws LowLevelException {
		throw new LowLevelException("LowLevelException-msg");
	}

	public static void fb() throws LowLevelException {
		fa();
	}

	public static void fc() throws MidLevelException {
		try {
			fb();
		} catch (LowLevelException e) {
			throw new MidLevelException("MidLevelException-msg", e);
		}
	}

	public static void fd() {
		try {
			fc();
		} catch (MidLevelException e) {
			throw new HighLevelException("HighLevelException-msg", e);
		}
	}

	public static void fe() {
		fd();
	}

	public static void main(String[] args) {
		try {
			fe();
		} catch (HighLevelException e) {
			e.printStackTrace();
		}
	}
}
